﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BOHVote.BLL;

namespace BOH.DataManagement
{
    public partial class ForeignLanguageModify : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ID"] != null)
                {
                    LoadLanguageByID(Request.QueryString["ID"].ToString());
                }
            }
        }

        public void LoadLanguageByID(string ID)
        {
            DataSet dst = OtherClass.getLanguageByID(ID);
            if (dst.Tables[0].Rows.Count > 0)
            {
                txtLanguageCode.Text = dst.Tables[0].Rows[0]["ForeignLanguageid"].ToString();
                txtLanguageName.Text = dst.Tables[0].Rows[0]["ForeignLanguageName"].ToString();
                drpStatus.SelectedValue = dst.Tables[0].Rows[0]["status"].ToString();
            }
        }

        protected void butSave_Click(object sender, EventArgs e)
        {
            string strLanguageCode = txtLanguageCode.Text;
            string strLanguageName = txtLanguageName.Text;
            string strStatus = drpStatus.SelectedValue;
            if (Request.QueryString["ID"] != null)
            {
                OtherClass.UpdateLanguage(strLanguageCode, strLanguageName, strStatus, Request.QueryString["ID"].ToString());
            }
            else
            {
                OtherClass.InsertLanguage(strLanguageCode, strLanguageName, strStatus);
            }

            Response.Redirect("ForeignLanguageList.aspx");
        }
    }
}
